/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'id',
        title: 'ID',
        type: 'number',
        columnClass: 'text-center width-20',
        fastSort: true,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'direction',
        title: '交易方向',
        type: 'string',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        codeTable:{
            1:$lang.direction.payment,
            2:$lang.direction.receive
        }
    },
    {
        id: 'createTime',
        title: '成交时间',
        type: 'date',
        format:'yyyy-MM-dd',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'range'
    },
    {
        id: 'dealPrice',
        title: '成交价格',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right',
        fastSort: true
    },
    {
        id: 'dealNumber',
        title: '成交数量',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right',
        fastSort: true,
        format:'#,##0.00'
    },

    {
        id: 'dealAmount',
        title: '交易总额',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right',
        fastSort: false,
        format:'#,##0.00'
    },
    {
        id: 'feeTrade',
        title: '交易费',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right',
        fastSort: false,
        format:'#,##0.00'
    },
    {
        id: 'taxYinhua',
        title: '印花税',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right',
        fastSort: false,
        format:'#,##0.00'
    },
    {
        id: 'feeGuohu',
        title: '过户费',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-right',
        fastSort: false,
        format:'#,##0.00'
    },
    {
        id: 'orderId',
        title: '订单id',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left',
        fastSort: false,
        hide:true
    },
    {
        id: 'investId',
        title: '投资人id',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left',
        fastSort: false,
        hide:true
    }
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'tradeLog/list.json',
    exportFileName: '资金记录列表',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {int:["id","userId","investId","tradeCredit","status","direction","orderId","dealNumber"],Timestamp:["buyTime","acceptTime","buyDealTime","eveningUpTime","sellTime","sellDealTime","createTime"],BigDecimal:["buyPrice","sellPrice","profitCount","taxYinhua","dealAmount","feeTrade","feeGuohu"]}
};

var grid = $.fn.DtGrid.init(dtGridOption);
//默认查询条件
grid.fastQueryParameters = {};
grid.fastQueryParameters['eq_order_id'] = $('#orderId').val();
if($('#investId').val() != '') {
    grid.fastQueryParameters['eq_user_id'] = $('#investId').val();
}



//排序
grid.sortParameter.columnId = 'id';
grid.sortParameter.sortType = 0;

//列表结束

//操作处理开始
var OperateHandle = function () {

    function _bindEvent() {

        //新增对话框初始化
        $("#addModal").on("show.bs.modal", function (event) {

        });

        //编辑对话框初始化
        $("#editModal").on("show.bs.modal", function (event) {

        });

        //模糊搜索
        $('#customSearch').click(function () {

        });
    }

    //外部可调用
    return {
        bindEvent: _bindEvent,
        delAdmin: _delAdmin
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});